package com.example.demo;

import org.junit.jupiter.api.Test;
import java.util.Scanner;

public class Ce {
    @Test
    public void a(){
        //原始字符串
        String s1 = "start";
        //星号字符串
        StringBuffer s2 = new StringBuffer("");
        for (int i = 0; i<s1.length();i++){
            s2.append("*");
        }
        Scanner sc = new Scanner(System.in);
        //猜对索引
        String s3 = "";
        while(s3.length() <= s1.length()){
            //猜对字符的索引
            int a = 0;
            s3 += a;
            System.out.println(s2);
            String y =sc.nextLine();
            for (int i = 0; i<s1.length();i++){
                if(y.equals(String.valueOf(s1.charAt(i)))){
                    a = i;
                    System.out.println("恭喜猜对了");
                    return;
                }else if(i > s1.length()-1){
                    System.out.println("猜错了还有"+"");
                }
            }
            //进行替换
            s2.replace(a,a+1,y);
        }


    }
}
